home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 4
/
Commodore_Free_Issue_04_2007_Commodore_Computer_Club.d64
/
t.a eeeben
< prev
next >
Wrap
Text File
|
2023-02-26
|
5KB
|
186 lines
u
Interview with Aleksi Eeeben
1) Emulation of a SID - a tough
enough job to do on PC, but how on
earth can someone even think of bring
the sound of the 64 into the
unexpanded 5 KB of the VIC-20?
Common sense says it's not possible,
so it had to be done with a little
madness. No, it's not really a trick,
but actually a quite faithful emulation
of the inner workings of SID. Phase-
accumulating oscillators are very
much the same. Everything is just
scaled down to such accuracy and
detail that a 1 MHz 8-bit processor
can handle.
2) Could you explain how you managed
to make this happen to someone who
does not understand that much of coding
like - well, let's say ... a nerd like me?
The emulation consists of four parts:
1. Tone generator - The heart of the
emulation, generates and mixes three
static voices and outputs the combined
sound through volume register 4-bit
DAC (exactly like playing samples on
C-64). Triangle, sawtooth, pulse Wave
(with 32 widths) and noise can be
selected with a jmp-switch and each
voice has volume setting of 0-7. This
code is running in an NMI timer
interrupt called at 6.1 kHz rate.
Locating the entire tone generator part
on zeropage, using self-modifying
code and counting cycles, I squeezed
the oscillator code to 30-39 cycles
per voice (depending on waveform), so
there's a few cycles left for other
routines too.
2. Original playroutine - 6502 and
6510 share the same instruction set,
so the same original routine from C-64
can be used directly. For VIC 20, all
writes to SID chip must be manually
patched to some other memory location,
since $D400-$D418 is ROM.
Also zeropage usage must be checked,
as almost entire zeropage is used by
the tone generator part. Luckily most
playroutines need only a few zero page
locations. And finally, if the play
routine itself is located under VIC
20 ROM's then it has to be relocated
somewhere else.
3. Register emulation and envelopes -
This routine is called in sync with the
playroutine. It's linked to IRQ and
called only once a frame (50 Hz). It
simply reads the SID register image
produced by the playroutine part and
then changes the inner state of the
tone generator accordingly. Sid Vicious
internal frequency values are SID-
frequency divided by a constant.
Waveform jmp-switches are set based
on SID image waveform registers. This
part also emulates the envelopes and
updates the level bits in tone
generator code. Gate bits are polled &
attack/release phases started as
required.
4. Noise emulation - Voices with noise
waveform read from a 16-sample buffer.
The buffer is constantly filled with
new random numbers whenever there is
free processor time.
3) Nevertheless the routine has to have
some kind of magic to it because you
state that on the 64 it could be used
to play 2-SID-Songs on just one SID -
now that is awkward because we are
talking about six voices here instead
of three.
What's the trick and how much
memory does that trick need, or in
other words: can we hope for someone
doing a six-voice-tune for a upcoming
game in the distant future?
On C-64 you can play 3 regular SID
voices and 3 emulated voices. The
emulated voices will take
approximately 50-70% of CPU time,
which makes it unsuitable for most
games. It's possible if your game is
not very CPU-intensive, but generally
it's probably better for title screens
and such.
The emulated voices are always
sounding a little rougher. Low- and
mid-range notes with pulse waveform
sound best, very authentic actually. So
arrange your basses, lower leads and
not-too-high pads in the emulated
voices. Also experiment with drums.
The emulated voices have a sharper
attack. Also the noise has a certain
unique character, although it can't
reach as high as SID.
4) Generally speaking: more memory,
more voices? Can this be topped by a
128 playing 9 voices or is 6 the limit
for the SID to manage/emulate?
It's not really a matter of memory. On
C-128 you could probably use the 2
MHz mode for doubling the mixing
rate to 12 kHz. 3 SID voices and 6
Emulated voices is possible, but you
need to rewrite the tone generator code
for high memory instead of zeropage
and this decreases the performance.
Pulse waveform is the fastest to
emulate, since it doesn't require a
table-lookup for the envelope levels
(level can be implemented directly
by changing the values of upper and
lower edge). VIC 20 NMI's waste a
few cycles because they jump through
ROM. Thus, 4 emulated pulse wave
voices should be doable on C-64 with
similar quality.
Sid Vicious sound examples recorded
from VICExvic:
www.cncd.fi/aeeben/temp/vic20-sid-
emu-upsidedown.mp3
www.cncd.fi/aeeben/temp/vic20-sid-
emu commando.mp3
www.cncd.fi/aeeben/temp/vic20-sid-
emu-zoids.mp3
www.cncd.fi/aeeben/temp/vic20-sid-
emu-uuno.mp3
These run in VICE xvic (remove all
extra memory and reset emulator Before
loading):
www.cncd.fi/aeeben/temp/upside.prg
www.cncd.fi/aeeben/temp/zoids.prg
The source code, work in progress:
www.cncd.fi/aeeben/temp/sidemu_sou
rce_v0.zip
Other stuff:
www.myspace.com/aleksieeben
www.cncd.fi/aeeben
interview printed with Permission from
http://www.cevi-aktuell.de.vu/ Magazine